package ldh.im.dto.codec.binery;

import io.netty.buffer.ByteBuf;
import ldh.im.dto.base.ErrorResp;

public class ErrorRecCodec extends ResultCodec<ErrorResp> {

    @Override
    public void encode(ErrorResp errorRec, ByteBuf byteBuf) {
        super.encode(errorRec, byteBuf);
        byteBuf.writeInt(errorRec.getErrorCode());
        writeString(byteBuf, errorRec.getErrorMsg());
    }

    @Override
    public void decode(ErrorResp loginRec, ByteBuf byteBuf) {
        super.decode(loginRec, byteBuf);
        loginRec.setErrorCode(byteBuf.readInt());
        loginRec.setErrorMsg(readString(byteBuf));
    }

    @Override
    public ErrorResp create() {
        return new ErrorResp();
    }
}
